import { HintBtnView } from "../mapUI/HintBtnView";
import { LayerManager } from "../../manager/LayerManager";
import { RightTopLayerLine } from "../../manager/RightTopLayerLine";
import { RightTopLayerIndex } from "../../manager/RightTopLayerIndex";
import { Cache } from "../../cache/Cache";
import { LevelLimitDefin } from "../../../common/defin/LevelLimitDefin";
import { EffectManager } from "../../manager/EffectManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { GameController } from "../../mvc/GameController";
import { GameManager } from "../../manager/GameManager";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
//class AchievementIconBtn
    
    export  class AchievementIconBtn extends HintBtnView
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.line = RightTopLayerLine.lineOne;
            this.index = RightTopLayerIndex.Achievement;
            this.createChildren();
            this.addListeners();
            return;
        }

        public showAchievementEffect(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            if (Cache.instance.role.entityInfo.level < LevelLimitDefin.AchievementIconEffectShowLevel) 
            {
                return;
            }
            if (arg1) 
            {
                loc1 = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
                loc2 = [loc1];
                EffectManager.glowFilterReg(this._achievementBtn, loc2, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._achievementBtn);
            }
            return;
        }

        /* internal  */createChildren(): void
        {
            this._achievementBtn = ObjCreate.createGLoadedButton(ResFileConst.AchievementIconBtn, 0, 0, 60, 50, this);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._achievementBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickAchievementHandler);
            return;
        }

        protected clickAchievementHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (Cache.instance.role.roleInfo.level < LevelLimitDefin.AchievementShowLevel) 
            {
                return;
            }
            if (GameController.achievement.isResFileGot) 
            {
                GameManager.instance.popupView(GameController.achievement.view);
            }
            else 
            {
                LoaderHelp.addResCallBack(ResFileConst.Achievement, this.onGetResFile);
            }
            return;
        }

        /* internal  */onGetResFile(): void
        {
            GameController.achievement.isResFileGot = true;
            GameManager.instance.popupView(GameController.achievement.view);
            return;
        }

        /* internal */ /* var */_achievementBtn: GLoadedButton;
    }
